package com.example.song.wlms.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by song on 2017/2/9.
 */

public class FragmentAdapter extends FragmentPagerAdapter {
    private List<String> titles;
    private List<Fragment> list;

    public FragmentAdapter(FragmentManager fm, List<String> titles, List<Fragment> list) {
        super(fm);
        this.titles = titles;
        this.list = list;
    }

    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public int getCount() {
        return list != null ? list.size() : 0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }
}
